var mongoose = require('./mongoose');
var Schema = mongoose.Schema;

var messageSchema = new Schema({
  channelType: {
    type: String,
    required: true
  },
  fromUserId: {
    type: String,
    required: true
  },
  toUserId: {
    type: String,
    required: true
  },
  msgTimestamp: {
    type: Number,
    required: true
  },
  timestamp: {
    type: Number,
    required: true
  },
  objectName: {
    type: String,
    required: true
  },
  content: {
    type: Schema.Types.Mixed,
    required: true
  },
  msgUID: {
    type: String,
    index: {unique: true, dropDups: true}
  },
  encodedFromUserId: String,
  encodedToUserId: String
});

module.exports = mongoose.webim.model('IMMessage', messageSchema);
